<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test</title>
</head>
<body>
<p id="demo"></p>
<script type="text/javascript">
    var x = "14";
    x = parseInt(x);
    var arr = [5, 7, 30, 26, 18, 9, 35, x];

    var arr2 = new Array();

    for (var i = 0; i < arr.length; i++) {
        for (var j = i+1; j < arr.length; j++) {
            for (var m = 0; m < arr.length; m++) {
                if (i == j || i == m || j == m) {
                    continue;
                }
                if (arr[i] + arr[j] == arr[m]) {
                    var arr3 = [arr[i], arr[j], arr[m]];
                    arr2.push(arr3);
                }
            }
        }
    }

    //方法一
    document.getElementById("demo").innerHTML = JSON.stringify(arr2);
    console.log(arr2);
    //方法二
    var c = JSON.stringify(arr2);
    alert(c);

</script>

</body>
</html>